/**
 * Created by callmesoul on 2017/4/10.
 */
// var jwt = require('jsonwebtoken');
var WechatApi = require('co-wechat-api');
module.exports = options => {
    return function* (next) {
        if(this.request.query && this.request.query.wid){
            var wechatId=this.request.query.wid;
            const wechat = yield this.model.Wechat.findOne({ where: { id: wechatId} });
			console.log("wechat",wechat);
            if(wechat.accessToken){
                wechat.accessToken=JSON.parse(wechat.accessToken);
            }
            this.session.wechat=wechat;
			console.log("session.wechat",this.session.wechat);
            yield next;
        }else {
            yield next;
        }

        // const wechatId=this.params.wechatId;



    };
};
